#pragma once
#include <QWidget>

#include "widgets.h"

class SDialog;
class SImageButton;
class S_WIDGETS_EXPORT SDialogTitle : public QWidget {
  Q_OBJECT

 public:
  enum eButtons {
    button_close = 0,
    button_max,
    button_restore,
    button_expand,
    button_topping
  };

  static const char kbtnSettingObjName[16];
  static const char kName[16];

  SDialogTitle(QWidget* parent = nullptr);

  void setTitle(QString& strTitle);
  void setChildWindow();
  void setPopupWindow();
  void setEnablePopup(bool);
  void setEnableTopping(bool);
  void setEnablePackup(bool);
  void setEnableDisplay(bool);
  void setEnableSetting(bool enabled);

 protected:
  void paintEvent(QPaintEvent* event) override;
  void mousePressEvent(QMouseEvent* e) override;
  void mouseReleaseEvent(QMouseEvent* event) override;
  void mouseDoubleClickEvent(QMouseEvent* e) override;
  void mouseMoveEvent(QMouseEvent* e) override;

 signals:
  void popup();
  void close();
  void full();
  void restore();
  void mouseDblClick();
  void setting();

 protected slots:
  void onButtonClick();

 protected:
  QString m_strTitle;
  bool m_enableTopping = true;
  bool m_enablePopup = true;
  bool m_acceptDblClick = false;
  bool m_bLButtonDown = false;
  bool m_enableDisplay = false;
  bool m_enableSetting = false;
  QPoint m_posMouseDown;

 protected:
  SDialog* m_pParent = nullptr;
  SImageButton* m_btnClose = nullptr;
  SImageButton* m_btnFull = nullptr;
  SImageButton* m_btnRestore = nullptr;
  SImageButton* m_btnPopup = nullptr;
  SImageButton* m_btnTopping = nullptr;
  SImageButton* m_btnDisplay = nullptr;
  SImageButton* m_btnHide = nullptr;
  SImageButton* m_btnSetting = nullptr;
};
